var assert = require('assert');
import { parseHtml } from '../src/parser.js';


describe("parse html:", function(){
    it('<a></a>', function () {
        let tree = parseHtml('<a></a>');
        assert.strictEqual(tree.children[0].tagName, "a");
    });

    it('<a href="www.baidu.com"></a>', function () {
        let tree =parseHtml('<a href="www.baidu.com"></a>');
        assert.strictEqual(tree.children.length, 1);
        assert.strictEqual(tree.children[0].tagName, "a");
    });

    it('<a href ></a>', function () {
        let tree =parseHtml('<a href ></a>');
        assert.strictEqual(tree.children[0].tagName, "a");
    });

    it('<a href allow ></a>', function () {
        let tree =parseHtml('<a href allow ></a>');
        assert.strictEqual(tree.children[0].tagName, "a");
    });

    it('<a href="www.baidu.com" allow ></a>', function () {
        let tree =parseHtml('<a href="www.baidu.com" allow ></a>');
        assert.strictEqual(tree.children[0].tagName, "a");
    });

    it('<a id=abc></a>', function () {
        let tree =parseHtml('<a id=abc></a>');
        assert.strictEqual(tree.children[0].tagName, "a");
    });

    it('<a id=abc/>', function () {
        let tree =parseHtml('<a id=abc/>');
        assert.strictEqual(tree.children[0].tagName, "a");
    });

    it('<a id=\'abc\' />', function () {
        let tree =parseHtml('<a id=\'abc\' />');
        assert.strictEqual(tree.children.length, 0);
    });

    it('<a />', function () {
        let tree =parseHtml('<a />');
        assert.strictEqual(tree.children.length, 1);
    });

    it('<A /> upper case', function () {
        let tree =parseHtml('<A />');
        assert.strictEqual(tree.children.length, 1);
    });

    it('<>', function () {
        let tree =parseHtml('<>');
        assert.strictEqual(tree.children.length, 1);
    });

    it('<a>123</a>', function () {
        let tree =parseHtml('<a>123</a>');
        assert.strictEqual(tree.children.length, 1);
    });

    it('<a>123</a>', function () {
        let tree =parseHtml('<a>123</a>');
        assert.strictEqual(tree.children.length, 1);
    });

    it('<a id="a">123<a/></a>', function () {
        let tree =parseHtml('<a id="a">123<a/></a>');
        assert.strictEqual(tree.children[0].tagName, "a");
    });

    it('<a id="a" href>123<a id="aa"/></a>', function () {
        let tree =parseHtml('<a id="a" href>123<a id="aa"/></a>');
        assert.strictEqual(tree.children[0].tagName, "a");
    });

    it('<a></b>', function () {
        let tree =parseHtml('<a></b>');
        assert.strictEqual(tree.children.length, 1);
    });

});
